﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dev.Control;
using Exp.BillDLL.biz;
using Exp.BillDLL.ety;
using Bill.BasDLL.ety;
using DevExpress.XtraSplashScreen;
using TT.Module.sysLogin;


namespace ExpBillMain.form
{
    public partial class frmExpDetail : BaseFormDev
    {
        bizExpDetail bzExpDetail;
        bizArea bzArea;
        public frmExpDetail()
        {
            InitializeComponent();
        }

        private void frmExpDetail_Load(object sender, EventArgs e)
        {
            bzExpDetail = new bizExpDetail(_Global.basSysPara);
            bzArea = new bizArea(_Global.basSysPara);

            IList<etyTmYmsYD> ilYmsYD = new List<etyTmYmsYD>();
            etyTmYmsYD eyEty = new etyTmYmsYD();

            ggcDocList.GridView = this.gridView1;
            string sMapingCols = "YID,YD_NO,CLIENT_NAME,YW_TYPE_DESC,SF_DESC,CITY_DESC,QX_DESC,YF_AMT,EXP_AMOUNT,CREATE_TIME,QTY,WGT,ELE_CONFIRM";
            string sMapingHeaderTxt = "序号,详情单号,客户名称,业务类型,省份,市,区,速递金额,计费金额,时间,数量,重量,电子客户确认";
            string sColumnWidth = string.Empty;
            ggcDocList.ColumnsMappingCreate(sMapingCols, sMapingHeaderTxt);
            this.winUtil.LoadGridLayout(ggcDocList);
            ggcDocList.DataSource = ilYmsYD;
            ggcDocList.GridView.OptionsView.ShowGroupPanel = true;

            //客户下拉
            sMapingCols = "CLIENT_NAME";
            sMapingHeaderTxt = "客户名称";
            sColumnWidth = "20";
            cboClient.ColumnsMappingCreate(sMapingCols, sMapingHeaderTxt, sColumnWidth);
            cboClient.DisplayMember = "CLIENT_NAME";
            cboClient.ValueMember = "CLIENT_ID";
            cboClient.DataSource = _Global.ilClient;

            //业务类型
            sMapingCols = "X_CNAME";
            sMapingHeaderTxt = "业务类型";
            sColumnWidth = "20";
            cboBussType.ColumnsMappingCreate(sMapingCols, sMapingHeaderTxt, sColumnWidth);
            cboBussType.DisplayMember = "X_CNAME";
            cboBussType.ValueMember = "X_CODE";
            cboBussType.DataSource = _Global.ilYwType;

            cboBussType.ItemIndex = 0;

            cboClient.Text = "康爱多";
            dtFrom.Value = new DateTime(2014, 1, 1);
        }

        public override etyQuickKey F9()
        {
            IList<etyTmYmsYD> ilYmsYD = new List<etyTmYmsYD>();
            etyTmYmsYD eyEty = new etyTmYmsYD();
            eyEty.FROM_DATE = dtFrom.Value.ToString("yyyyMMdd");
            eyEty.TO_DATE = dtTo.Value.AddDays(1).ToString("yyyyMMdd");
            if (cboClient.Text.Trim() != "")
            {
                eyEty.CLIENT_ID = cboClient.EditValue.ToString();
            }
            if (cboBussType.Text.Trim() != "")
            {
                eyEty.YW_TYPE = cboBussType.EditValue.ToString();
            }
            if (chkBilled.Checked)
                eyEty.Bill_Filter = "Billed";
            //找数据
            ilYmsYD = bzExpDetail.GetDetailPage(eyEty);
            srcBinding.DataSource = ilYmsYD;
            ggcDocList.DataSource = srcBinding;
            //ggcDocList.DataSource = ilYmsYD;
            return base.F11();
        }

        private void ggcDocList_DoubleClick(object sender, EventArgs e)
        {
            etyTmYmsYD eyTmYms = srcBinding.Current as etyTmYmsYD;
            if (eyTmYms.EXP_AMOUNT.Trim() == "") return;

            frmBillResult fmResult = new frmBillResult(eyTmYms);
            fmResult.ShowDialog();
        }

        private void cLabel4_DoubleClick(object sender, EventArgs e)
        {
            APP.SqlHelp.WriteLogEnabled = true;
        }


    }
}
